﻿package mortal.game.view.guild.otherpanel
{
    import Message.Game.*;
    import com.mui.controls.*;
    import extend.language.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.view.common.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class GuildApplyConditionPanel extends GuildOtherBasePanel
    {
        private var _btnDontNeedReply:GRadioButton;
        private var _btnNeedReply:GRadioButton;
        private var _btnOk:GButton;
        private var _comboVIP:GCheckBox;
        private var _comboFightPower:GCheckBox;
        private var _comboLevel:GCheckBox;
        private var _comboActivity:GCheckBox;
        private static var _instance:GuildApplyConditionPanel;

        public function GuildApplyConditionPanel(param1:ILayer = null)
        {
            super(param1);
            setSize(283, 292);
            if (_instance)
            {
                throw new Error("单例!");
            }
            return;
        }// end function

        override public function layoutUI() : void
        {
            super.layoutUI();
            pushUIToDisposeVec(UIFactory.textField("" + Language.getString(71129), 20, 40, 255, 44, this, GlobalStyle.textFormatPutong));
            this._btnDontNeedReply = UIFactory.radioButton("" + Language.getString(71130), 20, 60, 105, 22, this);
            this._btnNeedReply = UIFactory.radioButton("" + Language.getString(71131), 140, 60, 105, 22, this);
            this._btnDontNeedReply.groupName = "guildApplyCondition";
            this._btnNeedReply.groupName = "guildApplyCondition";
            this._btnDontNeedReply.configEventListener(Event.CHANGE, this.radioBtnChange);
            this._btnNeedReply.configEventListener(Event.CHANGE, this.radioBtnChange);
            pushUIToDisposeVec(UIFactory.textField("" + Language.getString(71132), 20, 85, 255, 44, this, GlobalStyle.textFormatPutong));
            this._comboVIP = UIFactory.checkBox("" + Language.getString(71133), 30, 105, 235, 22, this);
            this._comboVIP.setLabelStyle("textFormat", GlobalStyle.textFormatHuang2);
            this._comboVIP.setLabelStyle("disabledTextFormat", GlobalStyle.textFormatHui);
            this._comboFightPower = UIFactory.checkBox("" + Language.getString(71134), 30, 135, 235, 22, this);
            this._comboFightPower.setLabelStyle("textFormat", GlobalStyle.textFormatHuang2);
            this._comboFightPower.setLabelStyle("disabledTextFormat", GlobalStyle.textFormatHui);
            this._comboLevel = UIFactory.checkBox("" + Language.getString(71135), 30, 165, 235, 22, this);
            this._comboLevel.setLabelStyle("textFormat", GlobalStyle.textFormatHuang2);
            this._comboLevel.setLabelStyle("disabledTextFormat", GlobalStyle.textFormatHui);
            this._comboActivity = UIFactory.checkBox("" + Language.getString(71136), 30, 195, 235, 22, this);
            this._comboActivity.setLabelStyle("textFormat", GlobalStyle.textFormatHuang2);
            this._comboActivity.setLabelStyle("disabledTextFormat", GlobalStyle.textFormatHui);
            var _loc_1:* = UIFactory.textField("" + Language.getString(71137), 20, 220, 255, 44, this, GlobalStyle.textFormatLv);
            _loc_1.wordWrap = true;
            _loc_1.multiline = true;
            pushUIToDisposeVec(_loc_1);
            this._btnOk = UIFactory.gButton("" + Language.getString(71138), (283 - 50) / 2, 260, 50, 22, this);
            return;
        }// end function

        private function radioBtnChange(event:Event) : void
        {
            var _loc_2:* = this._btnNeedReply.selected;
            this._comboVIP.enabled = this._btnNeedReply.selected;
            var _loc_2:* = _loc_2;
            this._comboLevel.enabled = _loc_2;
            var _loc_2:* = _loc_2;
            this._comboFightPower.enabled = _loc_2;
            this._comboActivity.enabled = _loc_2;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._btnDontNeedReply.dispose(param1);
            this._btnNeedReply.dispose(param1);
            this._btnOk.dispose(param1);
            this._comboVIP.dispose(param1);
            this._comboFightPower.dispose(param1);
            this._comboLevel.dispose(param1);
            this._comboActivity.dispose(param1);
            this._btnDontNeedReply = null;
            this._btnNeedReply = null;
            this._btnOk = null;
            this._comboVIP = null;
            this._comboFightPower = null;
            this._comboLevel = null;
            this._comboActivity = null;
            return;
        }// end function

        override public function update() : void
        {
            super.update();
            var _loc_1:* = Cache.instance.guild.selfGuildInfo.applyCondition;
            if (_loc_1 == null)
            {
                return;
            }
            this._comboVIP.selected = _loc_1.vip > 0;
            this._comboFightPower.selected = _loc_1.combat > 0;
            this._comboLevel.selected = _loc_1.level > 0;
            this._comboActivity.selected = _loc_1.activity > 0;
            this._btnNeedReply.selected = _loc_1.isNeedReply;
            this._btnDontNeedReply.selected = !_loc_1.isNeedReply;
            return;
        }// end function

        override public function onMouseClick(event:MouseEvent) : void
        {
            var _loc_2:SGuildApplyCondition = null;
            super.onMouseClick(event);
            switch(event.target)
            {
                case this._btnOk:
                {
                    _loc_2 = new SGuildApplyCondition();
                    _loc_2.vip = this._comboVIP.selected ? (1) : (0);
                    _loc_2.combat = this._comboFightPower.selected ? (1) : (0);
                    _loc_2.level = this._comboLevel.selected ? (1) : (0);
                    _loc_2.activity = this._comboActivity.selected ? (1) : (0);
                    _loc_2.isNeedReply = this._btnNeedReply.selected;
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GUILD_SET_APPLY_CONDITION, _loc_2));
                    this.hide();
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }// end function

        override public function quickDispose() : void
        {
            return;
        }// end function

        public static function hasInstace() : Boolean
        {
            return _instance != null;
        }// end function

        public static function get instance() : GuildApplyConditionPanel
        {
            if (!_instance)
            {
                _instance = new GuildApplyConditionPanel;
            }
            return _instance;
        }// end function

    }
}
